<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: red;
            position: absolute;
        }
    </style>
</head>
<body>
    <div id="box"></div>

    <script>
        let box=document.getElementById("box");
        document.onclick=function(){
            box.style.left=event.clientX-box.offsetWidth/2+"px";
            box.style.top=event.clientY-box.offsetHeight/2+"px";
        }
    </script>
</body>
</html>